package com.suning.sawp.dto.esb;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;

/**
 * 
 * 功能描述： <br>
 * esb订单详情返回
 *
 * @author 12072522
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
@XStreamAlias("MbfBody")
public class OmsOrderDetailResp implements Serializable {

    /**
     */
    private static final long serialVersionUID = 1L;

    /**
     * 操作标志 Y成功 N失败
     */
    @XStreamAlias("operateFlag")
    private String operateFlag;

    /**
     * 错误编码
     */
    @XStreamAlias("errorCode")
    private String errorCode;

    /**
     * 错误提示
     */
    @XStreamAlias("errorMassage")
    private String errorMassage;

    @XStreamAlias("orderLists")
    private List<OmsOrderList> orderList;

    public String getOperateFlag() {
        return operateFlag;
    }

    public void setOperateFlag(String operateFlag) {
        this.operateFlag = operateFlag;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMassage() {
        return errorMassage;
    }

    public void setErrorMassage(String errorMassage) {
        this.errorMassage = errorMassage;
    }

    public List<OmsOrderList> getOrderList() {
        return orderList;
    }

    public void setOrderList(List<OmsOrderList> orderList) {
        this.orderList = orderList;
    }

    @Override
    public String toString() {
        return "OmsOrderDetailResp [operateFlag=" + operateFlag + ", errorCode=" + errorCode + ", errorMassage="
                + errorMassage + ", orderList=" + orderList + "]";
    }

    /**
     * 
     * 功能描述： <br>
     * oms订单列表
     *
     * @author 12072522
     * @see [相关类/方法]（可选）
     * @since [产品/模块版本] （可选）
     */
    @XStreamAlias("orderList")
    @XStreamConverter(OmsOrderList.Converter.class)
    public static class OmsOrderList implements Serializable {

        /**
         */
        private static final long serialVersionUID = 1L;

        public static class Converter implements com.thoughtworks.xstream.converters.Converter {

            @SuppressWarnings({ "rawtypes", "unchecked" })
            @Override
            public boolean canConvert(Class type) {
                return type.isAssignableFrom(OmsOrderList.class);
            }

            @Override
            public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
                throw new UnsupportedOperationException();

            }

            @Override
            public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {

                OmsOrderList omsOrderList = new OmsOrderList();
                while (reader.hasMoreChildren()) {
                    reader.moveDown();
                    if ("name".equals(reader.getNodeName())) {
                        omsOrderList.setName(reader.getValue());
                    }

                    if ("mobilePhoneNum".equals(reader.getNodeName())) {
                        omsOrderList.setMobilePhoneNum(reader.getValue());;
                    }

                    if ("orderbodyLists".equals(reader.getNodeName())) {
                        List<OmsOrderbodyList> omsOrderbodyLists = new ArrayList<OmsOrderbodyList>();
                        while (reader.hasMoreChildren()) {
                            reader.moveDown();
                            OmsOrderbodyList tem = new OmsOrderbodyList();
                            while (reader.hasMoreChildren()) {
                                reader.moveDown();
                                if ("deliveryAddrMain".equals(reader.getNodeName())) {
                                    tem.setDeliveryAddrMain(reader.getValue());
                                }
                                if ("orderItemId".equals(reader.getNodeName())) {
                                    tem.setOrderItemId(reader.getValue());
                                }
                                reader.moveUp();
                            }
                            omsOrderbodyLists.add(tem);
                            reader.moveUp();
                        }
                        omsOrderList.setOrderbodyLists(omsOrderbodyLists);
                    }
                    reader.moveUp();
                }

                return omsOrderList;
            }

        }

        /**
         * 收货人姓名
         */
        private String name;

        /**
         * 收货人手机号码
         */
        private String mobilePhoneNum;

        /**
         * 订单行信息
         */
        private List<OmsOrderbodyList> orderbodyLists;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getMobilePhoneNum() {
            return mobilePhoneNum;
        }

        public void setMobilePhoneNum(String mobilePhoneNum) {
            this.mobilePhoneNum = mobilePhoneNum;
        }

        public List<OmsOrderbodyList> getOrderbodyLists() {
            return orderbodyLists;
        }

        public void setOrderbodyLists(List<OmsOrderbodyList> orderbodyLists) {
            this.orderbodyLists = orderbodyLists;
        }

        @Override
        public String toString() {
            return "OmsOrderList [name=" + name + ", mobilePhoneNum=" + mobilePhoneNum + ", orderbodyLists="
                    + orderbodyLists + "]";
        }

    }

    /**
     * 
     * 功能描述： <br>
     * oms 订单行
     *
     * @author 12072522
     * @see [相关类/方法]（可选）
     * @since [产品/模块版本] （可选）
     */
    public static class OmsOrderbodyList implements Serializable {

        /**
         */
        private static final long serialVersionUID = 1L;

        private String orderItemId;

        private String deliveryAddrMain;

        public String getOrderItemId() {
            return orderItemId;
        }

        public void setOrderItemId(String orderItemId) {
            this.orderItemId = orderItemId;
        }

        public String getDeliveryAddrMain() {
            return deliveryAddrMain;
        }

        public void setDeliveryAddrMain(String deliveryAddrMain) {
            this.deliveryAddrMain = deliveryAddrMain;
        }

        @Override
        public String toString() {
            return "OmsOrderbodyList [orderItemId=" + orderItemId + ", deliveryAddrMain=" + deliveryAddrMain + "]";
        }

    }
}
